import http from "./http";

let api = {};

let fileAddr =  process.env.VUE_APP_fileAddr;
// 图片上传
api.uploadfile = async (params,config)=>{
    let res = await http.post("/api/web/file/upload",params,config);
    res.url = fileAddr + res.name;
    return Promise.resolve(res);
}

// base64 上传
api.uploadImgData = async (params,config)=>{
    let res = await http.post("/api/web/file/imgdata",params,config);
    res.url = fileAddr + res.name;
    return Promise.resolve(res);
}

// tag 创建
api.tagCreate = (params)=>{
    return http.post("/api/app/tag/add",params);
}
// tag 修改
api.tagUpdate = (params)=>{
    return http.post("/api/app/tag/update",params);
}

// tag 删除
api.tagRemove = (params)=>{
    return http.post("/api/app/tag/remove",params);
}
// tag 列表
api.tagList = (params)=>{
    return http.get("/api/app/tag/list",params);
}


// note 根据  tag 分类，并且统计数量
api.groupByTags = (params)=>{
    return http.get("/api/app/note/groupByTags",params);
}

// 获取根据id获取用户的信息
api.getUserById = (params)=>{
    return http.get("/api/web/user/info",params);
}

//注册
api.register = (params) => {
    return http.post("/api/web/user/register",params);
}

//登陆
api.login = (params) => {
    return http.post("/api/web/user/login",params);
}

//登出
api.logout = (params) => {
    return http.post("/api/web/loginout",params);
}

//新建笔记
api.newNote  = (params) => {
    return http.post("/api/app/note/add",params);
}

//获取笔记列表
api.noteList  = (params) => {
    return http.get("/api/app/note/list",params);
} 

//编辑笔记
api.editNote  = (params) => {
    return http.post("/api/app/note/update",params);
}

//删除笔记
api.delNote  = (params) => {
    return http.post("/api/app/note/remove",params);
}


export default api;
